<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Lokasi extends CI_Controller {
	
	function __construct()
	{
		parent::__construct();
		
		$this->load->helper('bantuan_helper');
		if(!$this->session->userdata('user_id') && !$this->session->userdata('user_display_name') ):
			redirect('backend');
		endif;
	}
	
	function index()
	{
		$data['latitude'] = getOption('latitude');
		$data['longitude'] = getOption('longitude');
		$data['title'] = 'Lokasi';
		$data['template'] = 'lokasi/index';
		$this->load->view('backend/index',$data);
	}
	
	function edit()
	{
		$this->form_validation->set_rules('latitude', 'Latitude','required');
		$this->form_validation->set_rules('longitude', 'Longitude','required');
		if ($this->form_validation->run() == FALSE){
			$data['latitude'] = getOption('latitude');
			$data['longitude'] = getOption('longitude');
			$data['title'] = 'Lokasi';
			$data['template'] = 'lokasi/edit';
			$this->load->view('backend/index',$data);
		}
		else{
			$datalatitude = array(
				'option_value' => $this->input->post('latitude')
				
			);
			$datalongitude = array(
				'option_value' => $this->input->post('longitude')
			);
			$this->db->where('option_name','latitude')->update('tb_option',$datalatitude);
			$this->db->where('option_name','longitude')->update('tb_option',$datalongitude);
			redirect('backend/lokasi');
		}
	}
}